
if exists (select 1 from sysobjects where name = 'get_dienstzeiten' and type = 'P')
begin
   drop procedure get_dienstzeiten
   print 'Procedure: get_dienstzeiten deleted ...'
end
go
create procedure get_dienstzeiten(
  @dienstid             int               = 2
)
as
begin
  set nocount on

  select dienstzeitid = DienstZeitID,
         dienstid = DienstID,
         von = CONVERT(CHAR(5), Von, 14),
         bis = CONVERT(CHAR(5), Bis, 14),
         typ = case when Zeiteinheit = 'P'
                    then 'Pause'
                    else 'Arbeit'
               end,
         datumvon = datvon,
         datumbis = datbis,
         abteilungszeit = abteilungzeit
    from DienstZeit 
   where DienstID = @dienstid 

end
go
print 'Procedure: get_dienstzeiten done ...'
go
grant exec on get_dienstzeiten to prsadmins with grant option
go
grant exec on get_dienstzeiten to prsusers
go

